// Niz pokusaja login-a sa pokrkesnim podacima, poslednji parametri omogucavaju uspesan login.

package testproject;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class appBuilderLogin {
		
		  private WebDriver driver;
		  @Before
		  public void setUp() throws Exception {
		    driver = new FirefoxDriver();
		  }
		  
		  @Test
		  public void testApbLogin() throws Exception {
			  
			  // nevalidni podaci za login:
			  
			  driver.get("https://service.wmappbuilder.com/appbuilder/login");
			  driver.findElement(By.id("j_username")).sendKeys("bojan.peric");
			  driver.findElement(By.id("j_password")).sendKeys("Bp789De");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_password")).sendKeys("");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_password")).sendKeys("admin");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_username")).clear();
			  driver.findElement(By.id("j_username")).sendKeys("admin");
			  driver.findElement(By.id("j_password")).sendKeys("Bp789De");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_password")).sendKeys("");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_password")).sendKeys("admin");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_username")).clear();
			  driver.findElement(By.id("j_username")).sendKeys("");
			  driver.findElement(By.id("j_password")).sendKeys("Bp789De");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_password")).sendKeys("");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("j_password")).sendKeys("admin");
			  driver.findElement(By.id("proceed")).click();
			  
			  // validni podaci za login:
			  
			  driver.findElement(By.id("j_username")).clear();
			  driver.findElement(By.id("j_password")).clear();
			  driver.findElement(By.id("j_username")).sendKeys("bojan.peric");
			  driver.findElement(By.id("j_password")).sendKeys("Bp789Dev");
			  driver.findElement(By.id("proceed")).click();
			  driver.findElement(By.id("close")).click();
			  
		  }
		  
/*		  @After
		  public void tearDown() throws Exception {
		    driver.quit();

	}
*/

}
